<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>咨询测算查询</title> <%include("/common/include.html"){}%>
<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<style type="text/css">
.textbox {
	padding-right: 0px;
	background: url("${cxt !}/sb/themes/insdep/images/combo_arrow.png")
		no-repeat scroll right center transparent;
}
</style>
</head>
<body class="easyui-layout">
	<div id="dianyuanmessage" class="easyui-window" title="回访记录" data-options="collapsible:false,minimizable:false,maximizable:false,closable:true,resizable:true" style="width:750px;height:400px;padding:5px;" data-options="cls:'theme-panel-orange'" closed="true">
		<table id="tablevisit"></table>
	</div>
	<div data-options="region:'north',split: true,title:'快速查询'" style="height: 200px; padding: 10px;">
		<form id="measureStatisticFrom" action="${cxt!}/measureStatistic/excel">
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">开始时间</label>
				<input name="_query.startTime" value='${date()}' class="easyui-datebox theme-textbox-radius"
					style="height: 32px; width: 212px; text-align: center" 
						data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
			</div>
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">结束时间</label>
				<input name="_query.endTime" value='${date()}' class="easyui-datebox theme-textbox-radius" style="height: 32px; width: 212px; text-align: center"
						data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
			</div>
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">代理商/门店</label>
				<input id="organ" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px; text-align: center"
					onclick="showMenu(); return false;" class="textbox" value="${curOrgan.name! }" />
				<input name="_query.selOrganIds" id="organIds" type="hidden" value="${curOrgan.ids! }">
			</div>
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">市场负责人</label>
				<input id="organMangerIds" name="_query.organMangerIds" class="easyui-combobox theme-textbox-radius"
					style="width: 212px; height: 32px; text-align: center;" data-options="editable: false">
			</div>
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">顾客分类</label>
				<#code type="select" name="_query.gkfl" code="code_gkfl" isSelectDef="false" class="easyui-combobox inputBox theme-textbox-radius"
				style="width:212px;height:32px;text-align:center;" dataOptions="editable:false"/>
			</div>
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">进店方式</label>
				<#code type="select" name="_query.jdfs" code="code_jdfs" isSelectDef="false" class="easyui-combobox inputBox theme-textbox-radius"
				style="width:212px;height:32px;text-align:center;" dataOptions="editable:false"/>
			</div>
			<div style="margin-bottom: 10px; float: left; margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">顾客反映</label>
				<#code type="select" name="_query.gkfy" code="code_gkfy" isSelectDef="false" class="easyui-combobox inputBox theme-textbox-radius"
				style="width:212px;height:32px;text-align:center;" dataOptions="editable:false"/>
			</div>
			<div style="margin-bottom: 10px; float: left; margin-top: 16px; margin-right: 10px;">
				<a href="#" onclick='searchFrom()' class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 212px">搜索</a>
			</div>
			<div style="margin-bottom: 10px;float:left;">
				<label class="label-top" style="width: 100%; display: block;">导出</label>
				<a href="#" onclick="queryCustomerExcel()" class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:212px">导出</a>
			</div>
		</form>
	</div>
	<div data-options="region:'center',border: false" style="overflow-x: hidden;">
		<table id="measureStatisticTable" style="width: 100%; height: 100%;">
		</table>
	</div>
	<div id="menuContent" class="menuContent" style="display: none; position: absolute; z-index: 10;">
		<ul id="organSelectTree" class="ztree" style="margin-top: 0; width: 200px;"></ul>
	</div>
	<script type="text/javascript">
		var $form = $('#measureStatisticFrom');
		function searchFrom() {
			$("#measureStatisticTable").datagrid('load',
					sy.serializeObject($form));
		}
		$(function() {
			var $form_div = $("#measureStatisticFrom div");
			winResize($form_div);
			$(window).resize(function() {//当调整浏览器窗口的大小时，发生 resize 事件
				winResize($form_div);
			})
		})
		function initMeasureStatisticTable(orgainIds) {

			$('#measureStatisticTable').datagrid({
				cls : "theme-datagrid",
				singleSelect : true,
				rownumbers : true, //显示序号
				pagination : true,
				pageSize : 10,
				url : "${cxt!}/measureStatistic/view",
				queryParams : sy.serializeObject($form),
				method : 'post',
				collapsible : true,
				columns : [ [ 
				              /* {
					field : 'number',
					title : '编号',
					width : 130,
					align : 'center'
				}, */
				{
					field : 'name',
					title : '姓名',
					width : 100,
					align : 'center'
				}, 
				/* {
					field : 'phone',
					title : '手机号',
					width : 100,
					align : 'center'
				},  */
				{
					field : 'sex',
					title : '性别',
					width : 40,
					align : 'center'
				}, {
					field : 'age',
					title : '年龄',
					width : 40,
					align : 'center'
				},{
					field : 'height',
					title : '身高',
					width : 80,
					align : 'center'
				}, {
					field : 'weight',
					title : '体重',
					width : 80,
					align : 'center'
				}, {
					field : 'jdr',
					title : 'jdr',
					width : 100,
					align : 'center',
					hidden : true
				}, {
					field : 'jdrname',
					title : '接待人',
					width : 100,
					align : 'center'
				}, {
					field : 'jsrids',
					title : 'jsr',
					width : 100,
					align : 'center',
					hidden : true
				}, {
					field : 'jsrname',
					title : '介绍人',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						if (row.jsrname) {
							return row.jsrname;
						} else {
							return "无";
						}
					}
				}, {
					field : 'jdfs',
					title : '进店方式',
					width : 100,
					align : 'center'
				}, {
					field : 'gkfl',
					title : '顾客分类',
					width : 100,
					align : 'center'
				}, {
					field : 'gkfy',
					title : '顾客反应',
					width : 100,
					align : 'center'
				}, {
					field : 'gxsj',
					title : '日期',
					width : 100,
					align : 'center'
				},  {
					field : 'gkhfxx',
					title : '顾客回访信息',
					width : 100,
					align : 'center',
					formatter:function(value,row,index){
						return '<a onclick='+'btn2(\'' + row.ids + '\')'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:green'+' class='+'l-btn-text'+'>查询</span></span></a>';
				}} ,
				{
					field : 'oname',
					title : '所属机构',
					width : 130,
					align : 'center'
				}
				] ],
				onLoadSuccess : function() {

				},
				onClickRow : function(rowIndex, rowData) {
				}
			});
		}
	</script>
	<script type="text/javascript">
		var setting = {
			async : {
				enable : true,
				url : '${cxt!}/common/getOrgenTree',
				autoParam : [ "id=ids" ],//, "name=n", "level=lv"
				type : "post"
			},
			view : {
				dblClickExpand : false
			},
			data : {
				simpleData : {
					enable : true
				}
			},
			callback : {
				onClick : onClick,
				onAsyncSuccess : organTreeOnAsyncSuccess
			}
		};
		//初始化市场负责人下拉框
		function initMangerSelect(ids) {
			var url = "/common/getOrganManger";
			var param = {
				'ids' : ids
			};
			var data = common_ajax.ajaxFunc(url, param, "json");
			data.unshift({
				'ids' : '-1',
				'name' : '-请选择-'
			});
			$('#organMangerIds').combobox({
				data : data,
				valueField : 'ids',
				textField : 'name',
				onLoadSuccess : function() {
					var val = $(this).combobox('getData');
					for ( var item in val[0]) {
						if (item == 'ids') {
							$(this).combobox('select', val[0][item]);
						}
					}
				}
			});
		}
		var flag = 0;
		function organTreeOnAsyncSuccess(event, treeId, msg) {
			if (flag == 0) {
				var organTree = $.fn.zTree.getZTreeObj("organSelectTree");
				var nodes = organTree.getNodes();
				initMangerSelect(nodes[0].id);
				initMeasureStatisticTable(nodes[0].id);
				flag = 1;
			}
		}
		function onClick(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("organSelectTree");
			var path = "";
			var sNodes = zTree.getSelectedNodes();
			if (sNodes.length > 0) {
				var node = sNodes[0].getPath();
				for (var i = 0; i < node.length; i++) {
					path += node[i].name + "/"
				}
			}
			var cityObj = $("#organ");
			cityObj.attr("value", path);
			$("#organIds").attr("value", treeNode.id);
			initMangerSelect(treeNode.id);
			hideMenu();
		}
		function showMenu() {
			var cityObj = $("#organ");
			var cityOffset = $("#organ").offset();
			$("#menuContent").css({
				left : cityOffset.left + "px",
				top : cityOffset.top + cityObj.outerHeight() + "px"
			}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn"
					|| event.target.id == "menuContent" || $(event.target)
					.parents("#menuContent").length > 0)) {
				hideMenu();
			}
		}
		$.fn.zTree.init($("#organSelectTree"), setting);
		function btn2(ids){
			loadViewDialog('查看回访信息', '${cxt!}/scallVisit/queryByCallVisit?ids=' + ids);
		}
		function queryCustomerExcel(){
			$('#measureStatisticFrom').submit();
		}
	</script>
</body>
</html>
